﻿using FellowshipOne.API.Base.Interfaces;
using FellowshipOne.API.Events.Sets;

namespace FellowshipOne.API.Realms
{
    public interface IEventsRealm
    {
        IApiSet<Events.Model.AttendanceSummary> AttendanceSummary { get; }
        IAttendance Attendance { get; }
        IApiSet<Events.Model.AttendanceCollection> AttendanceCollection { get; }
    }
    public class EventsRealm : IEventsRealm
    {
        #region Properties
        F1OAuthTicket Ticket { get; set; }
        string BaseUrl { get; set; }

        private IApiSet<Events.Model.AttendanceSummary> _attendanceSummary;
        private IAttendance _attendance;
        private IApiSet<Events.Model.AttendanceCollection> _attendanceCollection;

        public IApiSet<Events.Model.AttendanceSummary> AttendanceSummary
            => _attendanceSummary ?? (_attendanceSummary = new AttendanceSummary(Ticket, BaseUrl));

        public IAttendance Attendance => _attendance ?? (_attendance = new Attendance(Ticket, BaseUrl));


        public IApiSet<Events.Model.AttendanceCollection> AttendanceCollection
            => _attendanceCollection ?? (_attendanceCollection = new AttendanceCollection(Ticket, BaseUrl));

        #endregion

        #region Constructor

        public EventsRealm(F1OAuthTicket ticket, string baseUrl)
        {
            Ticket = ticket;
            BaseUrl = baseUrl;
        }

        #endregion Constructor
    }
}
